#{extends 'common/frontMain.html' /}
#{set title:'通过手机重置密码页面' /}
<div class="xf_login_centent clr">
	<div class="xf_login_title xf_login_title2">
		<span class="xf_login_title_yhdl">重置密码</span>
	</div>
	<div class="xf_register_email">
		<ul class="xf_register_email_ul clr" id="xf_wyjkview_xxk">
			<li onClick="byEmail()">通过邮箱重置密码</li>
			<li class="xf_con_wyjk_r_liishot xf_con_wyjk_r_liwyhm">通过手机重置密码</li>
		</ul>
		#{form @savePasswordByMobile(), id:'resetPassword'}
		<div class="xf_con_wyjk_tentultbody">
			<ul class="xf_login_inputsrul xf_login_inputsrul_zhyhm">
				<li>
					<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">请输入绑定手机：</div>
					<div class="xf_login_inputsrul_r">
						<input class="xf_login_shurk" type="text" id="mobile" name="mobile">
					</div>
				</li>
				<li>
					<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">输入校验码：</div>
					<div class="xf_login_inputsrul_r">
						<input class="xf_login_shurk" type="text" id="code" name="code">
						<input type="button" onClick="getMobile()" id="teleTime" value="点击获取手机验证码"/>
					</div>
				</li>
				<li>
					<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">输入新密码：</div>
					<div class="xf_login_inputsrul_r">
						<input class="xf_login_shurk" type="password" id="password" name="password">密码由6-20位数字或字母组成
					</div>
				</li>
				<li>
					<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">再次输入新密码：</div>
					<div class="xf_login_inputsrul_r">
						<input class="xf_login_shurk" type="password" id="confirmPassword" name="confirmPassword" >
					</div>
				</li>
				<li>
					<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">&nbsp;</div>
					<div class="xf_login_inputsrul_r">
						<a href="javascript:void(0);" class="xf_con_inputfbjk" onClick="resetPassword()">确定</a>
					</div>
				</li>
			</ul>
		</div>
		#{/form}
	</div>
</div>
<!-- 底部阴影 -->
<div class="xf_login_kjyy"></div>
<script>
     
     function resetPassword(){
        if($("#mobile").val() == ''){
            alert("请输入手机号码");
            return;
            
        }  
     
        if($("#code").val() == ''){
            alert("请输入校验码");
            return;
        }
        
        if(!$("#mobile").val().isMobileNum()) {
        	alert("请输入正确的手机号码");
            return;
       }
       
       var password = $("#password").val();
		   
      if(password == ""){
          alert("请设置您的密码");
          return; 
      }else if(password.length < 6){
         alert("密码长度为6-20个字符"); 
         return;
      }else if(password.length >20){
          alert("密码长度为6-20个字符"); 
          return;
      }else if(!/[a-zA-Z\d]{6,20}/.test(password)){
     	  alert("密码由6-20位数字或字母组成");
     	  return;
      }
		      
	  var confirmPassword = $("#confirmPassword").val();
	    
      if(confirmPassword == ""){
           alert("请输入密码确认"); 
           return;
      }else if(confirmPassword != $("#password").val()){ 
           alert("两次输入的密码不一致"); 
           return;
      } 
      $("#resetPassword").submit();
    }
      
	function byEmail(){
        window.location.href = "@{resetPasswordByEmail()}";
    }
    
    function getMobile(){
        var verifyMobileForResetPW = #{jsAction @verifyMobileForResetPW(':mobile')/}
		$.post(verifyMobileForResetPW({mobile:$("#mobile").val()}),function(data){
		    var arr = eval(data);
		      
		    if(arr.error.code < 0){
		        alert(arr.error.msg);
		        return;
		    } 
		    
		    teleCodeTimer("teleTime");
		});
    }
</script>
